package cqie.personal.frame.mapper;

import cqie.personal.frame.entity.CourseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Yeeeeee
 * @since 2021-09-28
 */
@Mapper
public interface CourseInfoMapper extends BaseMapper<CourseInfo> {
    @Insert("INSERT INTO " +
            " course_class_user(class_id , uid , course_id , create_time , create_person , last_upgrade_time , last_upgrade_person )" +
            " VALUE(#{classId} , #{uid} , #{courseId} ,#{date} , #{operator}  ,#{date} , #{operator} )")
    Integer addCourseTable(Integer operator, Date date, Integer uid, Integer classId, Integer courseId);

    @Select(" SELECT id,course_name FROM course_info WHERE id NOT IN(SELECT course_id FROM course_class_user WHERE class_id = #{id}) ")
    List<CourseInfo> getCourseClass(Integer id);
}
